﻿<?php
$data = array();

$json = array();
$cn=new mysqli("127.0.0.1","root","159456");  
mysqli_select_db($cn,"yzs");  
mysqli_query($cn,"set character set 'utf8'");  
mysqli_query($cn,"set names 'utf8'");  


$sql="SELECT t.`subject`,message,t.tid FROM pre_forum_post p INNER JOIN pre_forum_thread t ON t.tid=p.tid";
$ku=mysqli_query($cn,$sql);


while($rs=mysqli_fetch_array($ku)){
  preg_match_all("/\[img\]([^<>]+)\[\/img\]/Uisx",$rs[message],$nn);
  for($i=0;$i<count($nn[1]);$i++){
	  $d=array();
      $d[title]=$rs[subject];
      $d[image]=$nn[1][$i];
	  $d[url]="/forum.php?mod=viewthread&tid={$rs[tid]}";
	  $json[]=$d;
  }
}


echo json_encode( $json );
?>